package com.sunmouse.toolkit.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sunmouse.toollib.adapter.BasicRecyclerAdapter;
import com.sunmouse.toolkit.R;
import com.sunmouse.toolkit.bean.ExceptionBean;

import java.util.List;

/**
 * Created by Administrator on 2017/9/30 0030.
 */
public class ExceptionAdapter extends BasicRecyclerAdapter<ExceptionBean,ExceptionAdapter.ViewHolder> {


    public ExceptionAdapter(List<ExceptionBean> list, Context context) {
        super(list, context);
    }

    @Override
    protected View bindConvertView(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return inflater.inflate(R.layout.adapter_exception, parent, false);
    }

    @Override
    protected ViewHolder bindHolder(View v) {
        return new ViewHolder(v);
    }

    @Override
    protected void bindData(List<ExceptionBean> list, ViewHolder vh, int position) {
        ExceptionBean bean = list.get(position);
        vh.iconIv.setImageResource(R.mipmap.ic_launcher);
        vh.nameTv.setText(bean.getStationName());
        vh.levelTv.setText(bean.getLevel());
        vh.descTv.setText(bean.getDesc());
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView iconIv;
        TextView nameTv;
        TextView levelTv;
        TextView descTv;

        public ViewHolder(View v) {
            super(v);
            this.iconIv = (ImageView) v.findViewById(R.id.icon_iv);
            this.nameTv = (TextView) v.findViewById(R.id.title_tv);
            this.levelTv = (TextView) v.findViewById(R.id.level_tv);
            this.descTv = (TextView) v.findViewById(R.id.desc_tv);
        }
    }
}
